package net.daum.hibernate;

import java.io.File;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
import org.hibernate.tool.ant.Hbm2DDLExporterTask;
import org.hibernate.tool.ant.HibernateToolTask;

public class SchemaExport {
	public static void main(String[] args) {
		HibernateToolTask hibernateToolTask = new HibernateToolTask();
		hibernateToolTask.createConfiguration().setConfigurationFile(new File("hibernate.cfg.xml"));
		hibernateToolTask.setClasspath(new Path(new Project()));
		
		Hbm2DDLExporterTask exporterTask = new Hbm2DDLExporterTask(hibernateToolTask);
		exporterTask.setDrop(true);
		exporterTask.setCreate(true);
		exporterTask.setExport(true);
		exporterTask.setOutputFileName("Message.sql");
		exporterTask.setDelimiter(";");
		exporterTask.setFormat(true);
		exporterTask.execute();
	}
}
